********************************************************************************
*																		       *
* 							VAP								 				   *
*								     									       *
********************************************************************************

* -----> This do-file: All tables and graphs relying on sentiment analysis

********************************************************************************


set more off
clear all
set matsize 3000
set maxvar 10000

************************************

* Path 

if "`c(username)'"=="Juan S. Morales" | "`c(username)'"=="jmorales"{
	global PathData = "C:/Users/`c(username)'/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Data/"
	global PathFig = "C:/Users/`c(username)'/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Figures/"
	global PathTab = "C:/Users/`c(username)'/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Tables/"
	}
else { 
	global PathData = "/Users/JNG/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Data/"
	global PathFig = "/Users/JNG/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Figures/"
	global PathTab = "/Users/JNG/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Tables/"
	} 

use "${PathData}tweets_poland.dta", clear

***Basic data cleaning and generate basic controls****
sort screen_name
merge screen_name using "${PathData}mayors.dta"
drop if mayor==1
drop mayor
drop _merge

gen date = substr(created_at,1,10)
gen month = substr(date,6,2)
gen year = substr(date,1,4)
gen day = substr(date,9,2)
gen hour = substr(created_at,12,2)
destring(month), replace
destring(year), replace
destring(day), replace
destring(hour), replace
gen time = (year-2012)*12 + month
gen timeD = (year-2012)*365 + (month==2)*31 + (month==3)*(31+28) + (month==4)*(31*2 + 28) + (month==5)*(31*2 + 28 +30) + (month==6)*(31*3 + 28 +30) + (month==7)*(31*3 + 28 + 30*2) + (month==8)*(31*4 + 28 + 30*2) + (month==9)*(31*5 + 28 + 30*2) + (month==10)*(31*5 + 28 + 30*3) + (month==11)*(31*6 + 28 + 30*3) + (month==12)*(31*6 + 28 + 30*4) + day + 1*((month>2 & year==2012)|(year>2012))
gen week = round(timeD/7)
gen date2 = mdy(month, day, year)

gen text_l = lower(text)
replace text = text_l
drop text_l
replace text = subinstr(text, "á", "a",.) 
replace text = subinstr(text, "é", "e",.) 
replace text = subinstr(text, "í", "i",.) 
replace text = subinstr(text, "ó", "o",.) 
replace text = subinstr(text, "ú", "u",.)
replace text = subinstr(text, "ñ", "nh",.)
replace text = subinstr(text, ",", " ",.)
replace text = subinstr(text, `"""',  "", .)
replace text = subinstr(text, ".", " ",.) 
replace text = subinstr(text, "-", " ",.)
replace text = subinstr(text, "!", " ",.) 
replace text = subinstr(text, "/", " ",.)
replace text = subinstr(text, "…", " ",.)
replace text = subinstr(text, ":", " ",.)
replace text = subinstr(text, ";", " ",.)
* replace text = subinstr(text, "#", "",.)
* replace text = subinstr(text, "@", "",.)
forvalues i = 1(1)7 {
	replace text = subinstr(text, "  ", " ",.)
}
capture drop gg_*
gen gg_hashtag = strpos(text, "#")>0
gen gg_at = strpos(text, "@")>0
gen gg_reply = in_reply_to_user!=""
*at zero for this dataset
gen gg_rt = strpos(text, "rt ") == 1
gen gg_http = strpos(text, "http")>0



sort id
merge id using "${PathData}tweets_sentiment_coded_300.dta"



***** Coding VARIABLES (general) *****

gen dOfWeek = mod(date2,7)
replace dOfWeek = dOfWeek - 2
replace dOfWeek = dOfWeek + 7 if dOfWeek<1

drop gg_rt
gen gg_rt = strpos(text, "rt ") == 1

gen gg_adamowicz = strpos(text, "adamowicz")>0

gen log_rt = log(rt_count + 1)
gen log_fav = log(favcount + 1)
gen log_engagement = log(rt_count + favcount + 1)
egen userid = group(screen_name)
bysort date2 userid: gen N_du = _N



**** Coding TREATMENT (Adamowicz) *******

	
gen dayC_ada = date2 - 21562
gen dayC_sq_ada = dayC_ada*dayC_ada
gen dayC_cu_ada = dayC_ada*dayC_ada*dayC_ada
gen post_ada = date2>=21562
gen dayC_post_ada = dayC_ada*post_ada
gen dayC_sq_post_ada = dayC_sq_ada*post_ada
gen dayC_cu_post_ada = dayC_cu_ada*post_ada
gen dayC_opos_ada = dayC_ada*opposition
gen dayC_sq_opos_ada = dayC_sq_ada*opposition
gen dayC_cu_opos_ada = dayC_cu_ada*opposition
gen dayC_opos_post_ada = dayC_ada*opposition*post_ada
gen dayC_sq_opos_post_ada = dayC_sq_ada*opposition*post_ada
gen dayC_cu_opos_post_ada = dayC_cu_ada*opposition*post_ada
gen post_opo_ada = post_ada*opposition
gen post_gob_ada = post_ada*government

gen hour_sq = hour*hour
gen hour_cu = hour*hour*hour

bysort userid: gen n_u = _n
gen ffd_dayssinceE_ada = 99999
gen ffd_targetdate_ada = 21562
foreach targetdate in 21562 {
	replace ffd_dayssinceE_ada = (date2-`targetdate') if (abs(date2-`targetdate')<=abs(ffd_dayssinceE_ada))
	replace ffd_targetdate_ada = `targetdate' if (abs(date2-`targetdate')<=abs(ffd_dayssinceE_ada))
}
gen event_days_ada = date2-21562

gen timeWindow0_ada = ffd_dayssinceE_ada>-3 & ffd_dayssinceE_ada<2
gen timeWindow1_ada = ffd_dayssinceE_ada>-6 & ffd_dayssinceE_ada<5
gen timeWindow2_ada = ffd_dayssinceE_ada>-11 & ffd_dayssinceE_ada<10
gen timeWindow3_ada = ffd_dayssinceE_ada>-16 & ffd_dayssinceE_ada<15
gen timeWindow4_ada = ffd_dayssinceE_ada>-21 & ffd_dayssinceE_ada<20
gen timeWindow5_ada = ffd_dayssinceE_ada>-31 & ffd_dayssinceE_ada<30





**** Coding OTHER MENTIONS *******


replace text = " " + text
gen opMentions = strpos(text," rzd") + strpos(text," min ") + strpos(text,"minist") + strpos(text,"wicemin") + strpos(text,"pis ") + strpos(text,"tvp") + strpos(text,"andruszkiewicz") + strpos(text,"berni_krynick") + strpos(text,"budet") + strpos(text,"premier") + strpos(text,"morawieck") + strpos(text,"pisowsk") + strpos(text,"macierewicz") + strpos(text,"kaczysk") + strpos(text," msz ") + strpos(text,"tygodnik_sieci") + strpos(text,"smolesk") + strpos(text,"misiewicz") + strpos(text,"tasmykaczynsk") + strpos(text,"glapiski") + strpos(text,"glapinski") + strpos(text,"szydo") + strpos(text,"ziobro") + strpos(text,"zieliski") + strpos(text,"gowin") + strpos(text,"jbrudzinski") + strpos(text,"drelich") + strpos(text,"terlecki") + strpos(text,"sdownictw") + strpos(text,"pisorgpl") + strpos(text," nbp ") + strpos(text,"wicemarsz") + strpos(text," cba ") + strpos(text,"patryk jaki") + strpos(text,"policj") + strpos(text,"czaputowicz") + strpos(text,"gliski")
replace opMentions = opMentions>0
gen govMentions = strpos(text," opozycj") + strpos(text,"bzdrojewski") + strpos(text," lewic") + strpos(text,"olejnik") + strpos(text," lewicow") + strpos(text," biedro") + strpos(text," lewac") + strpos(text," psl_") + strpos(text," psl ") + strpos(text,"gazwyb") + strpos(text," nowick") + strpos(text," sikorsk") + strpos(text,"schetyn") + strpos(text," neuman") + strpos(text,"tomasz_lis") + strpos(text,"tomasz lis") + strpos(text," lis_tomasz") + strpos(text," tusk") + strpos(text," platform") + strpos(text,"trzaskowski_") + strpos(text,"platforma_org") + strpos(text,"klubnauer") + strpos(text," gw_") + strpos(text,"gazetawyborcza") + strpos(text,"tvn24")
replace govMentions = govMentions>0
replace govMentions = govMentions + strpos(text,"platforma_org")>0
replace govMentions = govMentions + strpos(text,"tomaszsiemoniak")>0
replace govMentions = govMentions + strpos(text,"arlukowicz")>0
replace govMentions = govMentions + strpos(text,"bbudka")>0
replace govMentions = govMentions + strpos(text,"andrzejhalicki")>0
replace govMentions = govMentions + strpos(text,"slawekneumann")>0
replace govMentions = govMentions + strpos(text,"schetynadlapo")>0
replace govMentions = govMentions + strpos(text,"mkierwinski")>0
replace govMentions = govMentions + strpos(text,"jangrabiec")>0
replace govMentions = govMentions + strpos(text,"achybicka")>0
replace govMentions = govMentions + strpos(text,"protasiewiczj")>0
replace govMentions = govMentions + strpos(text,"zpawlowicz")>0
replace govMentions = govMentions + strpos(text,"trzaskowski_")>0
replace govMentions = govMentions + strpos(text,"tomaszlenz")>0
replace govMentions = govMentions + strpos(text,"hannagw")>0
replace govMentions = govMentions + strpos(text,"asia_mucha")>0
replace govMentions = govMentions + strpos(text,"niesiolowskis")>0
replace govMentions = govMentions + strpos(text,"bbukiewicz")>0
replace govMentions = govMentions + strpos(text,"c_grabarczyk")>0
replace govMentions = govMentions + strpos(text,"ikatarasinska")>0
replace govMentions = govMentions + strpos(text,"ctomczyk")>0
replace govMentions = govMentions + strpos(text,"sowamarek")>0
replace govMentions = govMentions + strpos(text,"ireneuszras")>0
replace govMentions = govMentions + strpos(text,"kopacz_ewa")>0
replace govMentions = govMentions + strpos(text,"m_k_blonska")>0
replace govMentions = govMentions + strpos(text,"adam_korol")>0
replace govMentions = govMentions + strpos(text,"pomaska")>0
replace govMentions = govMentions + strpos(text,"henryka_henia50")>0
replace govMentions = govMentions + strpos(text,"miroslawanykiel")>0
replace govMentions = govMentions + strpos(text,"marianzembala")>0
replace govMentions = govMentions + strpos(text,"urszulaaugustyn")>0
replace govMentions = govMentions + strpos(text,"kr_szumilas")>0
replace govMentions = govMentions + strpos(text,"okladrewnowicz")>0
replace govMentions = govMentions + strpos(text,"mswitczak")>0
replace govMentions = govMentions + strpos(text,"jakubrutnicki")>0
replace govMentions = govMentions + strpos(text,"mjanyska")>0
replace govMentions = govMentions + strpos(text,"ziolkowskiszym")>0
replace govMentions = govMentions + strpos(text,"waldydzikowski")>0
replace govMentions = govMentions + strpos(text,"slawomirnitras")>0
replace govMentions = govMentions + strpos(text,"krzysztofbrejza")>0
replace govMentions = govMentions + strpos(text,"arkadiuszmyrcha")>0
replace govMentions = govMentions + strpos(text,"mwielichowska")>0
replace govMentions = govMentions + strpos(text,"gajewska_kinga")>0
replace govMentions = govMentions + strpos(text,"newsplatforma")>0
replace govMentions = govMentions + strpos(text,"grzegorzfurgo")>0
replace govMentions = govMentions + strpos(text,"bborusewicz")>0
replace govMentions = govMentions + strpos(text,"tomaszsiemoniak")>0
replace govMentions = govMentions + strpos(text,"rtyszkiewicz")>0
replace govMentions = govMentions + strpos(text,"jaroslawduda")>0
replace govMentions = govMentions + strpos(text,"zdzislaw_gawlik")>0
replace govMentions = govMentions + strpos(text,"arturgierada")>0
replace govMentions = govMentions + strpos(text,"a_marchewka")>0
replace govMentions = govMentions + strpos(text,"jacek_protas")>0
replace govMentions = govMentions + strpos(text,"wojciechsaluga")>0
replace govMentions = govMentions + strpos(text,"wslugocki")>0
replace govMentions = govMentions + strpos(text,"hannazdanowska")>0
replace govMentions = govMentions + strpos(text,"prezydentzuk")>0
replace govMentions = govMentions + strpos(text,"izabela_debska")>0
replace govMentions = govMentions + strpos(text,"tadeuszzwiefka")>0
replace govMentions = govMentions + strpos(text,"donaldtusk")>0
replace opMentions = opMentions + strpos(text,"piotr_naimski")>0
replace opMentions = opMentions + strpos(text,"pisorgpl")>0
replace opMentions = opMentions + strpos(text,"morawieckim")>0
replace opMentions = opMentions + strpos(text,"jbrudzinski")>0
replace opMentions = opMentions + strpos(text,"patrykjaki")>0
replace opMentions = opMentions + strpos(text,"andzyberto")>0
replace opMentions = opMentions + strpos(text,"kurskipl")>0
replace opMentions = opMentions + strpos(text,"piotrglinski")>0
replace opMentions = opMentions + strpos(text,"jaroslaw_gowin")>0
replace opMentions = opMentions + strpos(text,"stkarczewski")>0
replace opMentions = opMentions + strpos(text,"marekkuchcinski")>0
replace opMentions = opMentions + strpos(text,"beataszydlo")>0
replace opMentions = opMentions + strpos(text,"beatamk")>0
replace opMentions = opMentions + strpos(text,"e_rafalska")>0
replace opMentions = opMentions + strpos(text,"krystpawlowicz")>0
replace opMentions = opMentions + strpos(text,"ziobropl")>0
replace opMentions = opMentions + strpos(text,"beatakempa_kprm")>0
replace opMentions = opMentions + strpos(text,"mblaszczak")>0
replace opMentions = opMentions + strpos(text,"macierewicz_a")>0
replace opMentions = opMentions + strpos(text,"elzbietawitek")>0
replace opMentions = opMentions + strpos(text,"_annazalewska")>0
replace opMentions = opMentions + strpos(text,"michaldworczyk")>0
replace opMentions = opMentions + strpos(text,"latostomasz")>0
replace opMentions = opMentions + strpos(text,"slawzawislak")>0
replace opMentions = opMentions + strpos(text,"wassermann_ma")>0
replace opMentions = opMentions + strpos(text,"arekmularczyk")>0
replace opMentions = opMentions + strpos(text,"w_bernacki")>0
replace opMentions = opMentions + strpos(text,"mareksuski")>0
replace opMentions = opMentions + strpos(text,"akosztowniak")>0
replace opMentions = opMentions + strpos(text,"minenergii")>0
replace opMentions = opMentions + strpos(text,"a_czartoryski")>0
replace opMentions = opMentions + strpos(text,"mariuszkaminsk")>0
replace opMentions = opMentions + strpos(text,"sasinjacek ?")>0
replace opMentions = opMentions + strpos(text,"bogdan_rzonca")>0
replace opMentions = opMentions + strpos(text,"andrzejszlachta")>0
replace opMentions = opMentions + strpos(text,"mrirw_gov_pl")>0
replace opMentions = opMentions + strpos(text,"d_piontkowski")>0
replace opMentions = opMentions + strpos(text,"mkidn_gov_pl")>0
replace opMentions = opMentions + strpos(text,"stanislaw_szwed")>0
replace opMentions = opMentions + strpos(text,"szymongizynski")>0
replace opMentions = opMentions + strpos(text,"izabelakloc")>0
replace opMentions = opMentions + strpos(text,"andrzejduda")>0
replace opMentions = opMentions + strpos(text,"annamkrupka")>0
replace opMentions = opMentions + strpos(text,"iwonaarent")>0
replace opMentions = opMentions + strpos(text,"joannalichocka")>0
replace opMentions = opMentions + strpos(text,"witoldczarneck3")>0
replace opMentions = opMentions + strpos(text,"tadeuszdziuba")>0
replace opMentions = opMentions + strpos(text,"zagorskimarek")>0
replace opMentions = opMentions + strpos(text,"marekgrobarczyk")>0
replace opMentions = opMentions + strpos(text,"amadamczyk")>0
replace opMentions = opMentions + strpos(text,"jerzykwiecinski")>0
replace opMentions = opMentions + strpos(text,"jemilewicz")>0
replace opMentions = opMentions + strpos(text,"witoldbanka")>0
replace opMentions = opMentions + strpos(text,"jczaputowicz")>0
replace opMentions = opMentions + strpos(text,"szumowskilukasz")>0
replace opMentions = opMentions + strpos(text,"j_kopcinska")>0
replace opMentions = opMentions + strpos(text,"profkarski")>0
replace opMentions = opMentions + strpos(text,"ryszardterlecki")>0
replace opMentions = opMentions + strpos(text,"r_czarnecki")>0
replace opMentions = opMentions + strpos(text,"grzegorzczelej")>0
replace opMentions = opMentions + strpos(text,"anita_cz")>0
replace opMentions = opMentions + strpos(text,"ministerjurgiel")>0
replace opMentions = opMentions + strpos(text,"cymanskitadeusz")>0
replace opMentions = opMentions + strpos(text,"jacekzalek")>0
gen mentionOther = (opMentions & opposition) | (govMentions & government)
replace mentionOther = 0 if mentionOther == .


**** Coding other VARIABLES *******


gen post_mention_ada = post_ada*mentionOther
gen post_opo_mention_ada = post_ada*opposition*mentionOther
gen opo_mention = opposition*mentionOther

gen mention_ada = mentionOther*gg_adamowicz
gen opo_ada = opposition*gg_adamowicz
gen mention_opo_ada= mentionOther*gg_adamowicz*opposition



drop n_u
bysort userid: gen n_u=_n
bysort userid: gen N_u=_N
drop if N_u<10
reg log_engagement i.userid if !post_ada
predict popularity
egen popRankT = rank(-popularity) if n_u==1 & opposition, unique
bysort userid: egen popRankO = mean(popRankT)
drop popRankT
egen popRankT = rank(-popularity) if n_u==1 & government, unique
bysort userid: egen popRankG = mean(popRankT)
drop popRankT
gen popRankWithin = popRankG if government
replace popRankWithin = popRankO if opposition
egen popRankT = rank(-popularity) if n_u==1, unique
bysort userid: egen popRank = mean(popRankT)
drop popRankT

reg mentionOther i.userid if !post_ada
predict mentioner

sum mentioner if n_u==1 & opposition, det


label variable post_opo_ada "Post x opposition"
label variable opposition "Opposition"
label variable post_ada "Post"


label variable mentionOther "Mention rival"
label variable post_mention_ada "Post x Mention rival"

bysort userid: egen meanNGallT = mean(mentionOther)
bysort userid: egen meanNGall = mean(meanNGallT)
drop meanNGallT

gen post_ngA = post_ada*mentioner
label variable post_ngA "Post x Negative campaigner"


bysort userid: egen meanPopT = mean(log_engagement) if !post_ada
bysort userid: egen meanPop = mean(meanPopT)
drop meanPopT

gen post_pop = post_ada*meanPop
label variable post_pop "Post x popularity"


gen event_days_ada_M = event_days_ada+1000
replace event_days_ada_M=. if event_days_ada_M<0
bysort userid date2: gen n_tweets=_N
bysort userid date2: gen _tweets=_n
gen log_n_tweets=ln(n_tweets)

***words for sentiment***
foreach varn in si pl platforma pis org gov minister nbp tvp prezydenta polska ju tomaszsiemoniak schetynadlapo pawa kaczyski temu sprawapolek moe macierewicz dzi bdzie adamowicza pisorgpl newsplatforma chce bd the spotkanie salvini rzdu gociem dziki czarnecki adamowicz zmian wie polsce leszczyna info dziaania dobra andruszkiewicz and adam zo wspopracy ws wpolityce wiceminister wiadomo ustawy tvn tuska stycznia sowa schwertnerpl ryszard republikatv prezes pose polski polityka pastwa opozycji of nienawici ni musimy mowi morawieckim morawiecki mona min konwencji kobieta kadego jestemy glapiski gdaska europa eby dorota bya brejza amadamczyk zgryglas zapraszam zaoenia ycie wynagrodze wyborcza wspolnota wpolscepl wop woch wiowpn wicepremiera wi warszawa trzaskowski takich szefa swoimi sukiennik styczniowej spraw sowo slawomirnitras rzd rok rafalska radiomaryja pytania przyjtej projekt prezydent premiera premier pr poznajcie poniej polskieradio pokaza pitek obserwatorxy myl mkierwinski ministra mierci marszaek ludzie konferencji konferencja knf jkmmikke jeeli jedn in gowne gdasku gazeta dulkiewicz dot dopiero dokona dnia dni deklaracji ciszy chwil byy bh beatamk barbaraanowacka arkadiuszmyrcha andrzej znaczy zjednoczonaprawica zgasi zarzut zarobki zarobi zarabia zaprasza zapaci zabojstwo yczenia wywiad wystarczy wyrazy wszystk wskazuje wreszcie wraz wpywy wpywach wochy wobec wniosek wierzy wier wielkie wieczystego wicej wiadomoscitvp wchodzi warto wanie uytkowania ust usiuje umow umiechnita ue udziau tysice tyle twarz turnieju transportu tokfm tok takiego sytuacji syszelimy syna stefan stanislawski spotkaniu spoecznego solidarno sojuszu skorupka skoro skandalicznym sejm sb samym samo samemu rzonca rtyszkiewicz rozmowy rosyjskich rol rodziny razem rady radiowajedynka radio pytanie publ pszubartowicz psp ps projekcie programie program pro prezesa premierrp pracy pplewandowski powstanie powoana potrafi porozumienie polskiej polskapolicja polityk politycznej policja polecam pogldy podlaskiepo pochwalam poar plk pkp pikne pewnie pewien pawe parlamencie pamici osi opozycj okladrewnowicz odgrywa oczywicie obywatelska obecnoci nuda nowy niezaleznapl nienawi news nazywa nawzajem nauczycieli napisa najlepszym najbardziej myle mylami mswia mow mniej mkidn mir midzynarodowych miasta mgolbik mediach media mdre maych mateusz lx lwoj lutego ludziach ludzi lq lkwarzecha likwidacja licytacje lbalcerowicz latach kultury krzysztof kraju kraj kolegi kocu kobiet kn km kas kaczyskiego ka jutro joannakluzik jerzykwiecinski jeli jbrudzinski jarosaw jaka is instytucje inf imieniu hej gramy godz gminy gk gdansk future fundacjawosp for fm fina fakt ego efevxqhriw dzisiejsze dziennikarzy dziaa dwoch duym duda dostp donaldtusk donalda domow dokadnie dalej daje da czego ctomczyk coraz ciko cieszy chyba chwili chrzanowski chiefrobert chcia chcemy byo bm bliskimi beataszydlo beata baszczak barbarzystwa asf apel antyprzemocowej andruszkiewicza amerykanami aleksandra akt aklarenbach ak aferaknf ac {
	gen ggSEN_`varn' = strpos(text,"`varn' ")>0
}

reg sentiment ggSEN_*
predict sentimentPR

gen positive = 1 if sentimentPR>0
replace positive = 0 if sentimentPR<=0



**** Figure A9 ***


cibar sentiment if timeWindow3_ada, over1(mentionOther) over2(post_ada)
cibar sentimentPR if timeWindow3_ada, over1(mentionOther) over2(post_ada)



**** Figure A10 ***


reghdfe log_engagement ib1014.event_days_ada_M##positive if timeWindow3_ada & !gg_rt, abs(userid)
preserve
	regsave, ci
	gen days = _n
	drop if coef==0 & days>29
	/*we drop in 29 instead of 30 because of extra 0*/
	drop days
	gen days = _n
	set obs `=_N+1' 
	replace coef = 0 in 30
	replace coef = 0 in 60
	replace days = 60 in 60
	gen menOt = (days>30)
	replace days = days-30 if menOt

	forvalues var =1(1)30 {
		sum coef if days==`var' & !menOt
		replace coef = coef+r(mean) if menOt & days==`var'
	}

	replace days = days-15
	sum coef if days==-1 & !menOt
	gen coef_n = coef-r(mean) if !menOt

	sum coef if days==-1 & menOt
	replace coef_n = coef-r(mean) if menOt

	graph twoway (lpoly coef_n days if menOt & days<0, lp(dash) bwidth(6) color(red) msize(small)) (lpoly coef_n days if menOt & days>0, lp(dash) bwidth(6) color(red) msize(small)) (lpoly coef_n days if !menOt & days<0, bwidth(6) lp(line) color(eltgreen) msize(small)) (lpoly coef_n days if !menOt & days>0, bwidth(6) lp(line) color(eltgreen) msize(small)) (lpolyci coef_n days if menOt & days<0, bwidth(7) pwidth(7) level(90) lwidth(none) color(red%20)) (lpolyci coef_n days if menOt & days>0, bwidth(7) pwidth(7) level(90) lwidth(none) color(red%20)) (lpolyci coef_n days if !menOt & days>0, bwidth(7) pwidth(7) level(90) lwidth(none) color(eltgreen%20)) (lpolyci coef_n days if !menOt & days<0, bwidth(7) pwidth(7) level(90) lwidth(none) color(eltgreen%20))  (scatter coef_n days if !menOt & coef_n>-1 & coef_n<1, msymbol(Oh) color(eltgreen) msize(small)) (scatter coef_n days if menOt & coef_n>-1 & coef_n<1, msymbol(X) msize(medium) graphregion(color(white)) legend( cols(1) order(1 "Positive message" 3 "Non-positive message")) ytitle("Tweet engagement", size(large)) xtitle("Days since event", size(large)) lwidth(0.3 0.3) color(red) tline(0, lp(solid) lc(grey)) graphregion(lwidth(large)))
		graph export "${PathFig}FigureA10.png", replace
restore